﻿<template>
	<div style="padding:0px;">
		<el-form :model="dialogForm"  ref="dialogForm" :rules="rules" :label-width="formLabelWidth">
			<el-tabs v-model="activeName" type="card" >
			    <el-tab-pane label="基本项" name="first">
			    
				    <el-form-item label="经销商名称" >
				      <el-input  v-model="dialogForm.qczjg" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="人法网查询"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd" >
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="企业信用查询"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd" >
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="企业征信"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="实缴资本"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    
				    <el-form-item label="展车数量"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="工商网查询"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="月均汽车销售额"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="法人征信"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="法人身份核查"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="经营地使用时长"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="经营地址性质"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="经营地址面积"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="经营时长"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="综合评分"  class="half">
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="小计"  class="">
				      <el-input  v-model="dialogForm.qczjg" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="合计" >
				      <el-input  v-model="dialogForm.qczjg" auto-complete="off" disabled ></el-input>
				    </el-form-item>

			    </el-tab-pane>
			    <el-tab-pane label="加分项" name="second">
				    <el-form-item label="售后" >
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				  	<el-form-item label="行业影响力" >
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				    <el-form-item label="连锁店" >
				        <el-select v-model="dialogForm.region" :disabled="!dialogSendData.isAdd">
					      <el-option label="银行卡1" value="shanghai">银行卡1</el-option>
					      <el-option label="银行卡2" value="beijing">银行卡2</el-option>
					    </el-select>
				    </el-form-item>
				  	<el-form-item label="小计" >
				      <el-input v-model="dialogForm.qczjg" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				    <el-form-item label="合计" >
				      <el-input  v-model="dialogForm.qczjg" auto-complete="off" disabled ></el-input>
				    </el-form-item>
				   
			    </el-tab-pane>
			</el-tabs>
			<div style="text-align:right;margin-top:15px;">
				 <el-button @click="returnBack">返 回</el-button>
				 <el-button  v-if="dialogSendData.isAdd" type="primary" @click="submitConfirmForm('dialogForm')">提 交</el-button>
			</div>
		</el-form>
	</div>
</template>

<script>
    import qiniu from '@/views/qiniu/upload'
    import agentHttp from '@/utils/agentHttp.js'
	export default{
		components:{qiniu},
		created(){		
			if(this.dialogSendData.id!==""){
	      		//修改
	      		this.selectData(); 
	      	}
        },
        
        updated(){
        },
		props:['dialogSendData','tableData'],
		data(){
			return{
				activeName:"first",
				formLabelWidth:'170px',
				//弹窗或者查看页面信息
		         dialogForm:{
		          imagUrl:[],   //七牛图片地址
		          activityTheme:"",
		          linkUrl:""
		         
		        },
		        //验证规则
		        rules: {
		        },
                //七牛图片上传
		        qiniuImage:{
		        	id:"qiniuImage", //图片预览的id   
		        	image_uri:[]    //图片上传的列表  只含有url地址
		        },
		        packJson:{
					maxLength:3,   //最大图片数量
					accept:"",//image/gif,image/jpeg,image/jpg,image/png如果是这些，可以不传此参数
					size:4    //图片大小  单位兆
				}
			}
		},methods:{
			returnBack(){
				this.dialogSendData.dialogFormVisible=false;
			},
			submitConfirmForm(formName){
                this.$refs[formName].validate((valid) => {
		          if (valid) {
		          	if(this.dialogSendData.id===""){
		          		//添加
		          	    this.addData();
		          	}else{
		          		//修改
		          		this.editData();
		          	}
		          	setTimeout(()=>{
	            		this.dialogSendData.dialogFormVisible=false;
	            	},500)
		          } else {
		            this.$nextTick(()=>{
		          		this.$message.warning(document.getElementsByClassName('el-form-item__error')[0].innerText||"提交失败");
		                return false;
		          	})
		          }
		        });
			},
		    addData(){
		        this.dialogForm.imagUrl=this.qiniuImage.image_uri.join(",")
		        agentHttp.postJson('adminApi/admin/carousel/post_validated',this.dialogForm).then((data)=>{
		            if(data.success){  
		            	this.$emit('refreshTableData', null);
		            	this.$message.success(data.data||"添加成功");
		            } 
		        }) 
		    },
		    editData(){
		    	this.dialogForm.imagUrl=this.qiniuImage.image_uri.join(",")
		        agentHttp.putJson('adminApi/admin/carousel/put_validated',this.dialogForm).then((data)=>{
		            if(data.success){  
		            	this.$emit('refreshTableData', null);
		            	this.$message.success(data.data||"修改成功");
		            } 
		        }) 
		    },
		    selectData(){
		    	//console.log('取消下方注释，修改请求地址')
		        agentHttp.get('adminApi/admin/carousel/select_carousel/'+this.dialogSendData.id).then((data)=>{	
		            if(data.success){  
		            	this.dialogForm=data.data;
		            	this.qiniuImage.image_uri=data.data.imagUrl.split(',').notempty()//去掉为空的项，不然导致图片张数控制不准
		            } 
		        }) 
		    },

		}
	}
</script>
